package com.hxy.platform.admin.service.impl;

import com.hxy.platform.admin.dao.GalleryMapper;
import com.hxy.platform.admin.pojo.Gallery;
import com.hxy.platform.admin.service.GalleryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GalleryServiceImpl implements GalleryService {
    @Autowired
    private GalleryMapper galleryMapper;

    /**
     * 获取所有的服务
     * @return
     */
    @Override
    public List<Gallery> getAll() {
        return galleryMapper.getAll();
    }

    /**
     * 删除服务
     * @param id
     * @return
     */
    @Override
    public int deleteGallery(Integer id) {
        return galleryMapper.deleteByPrimaryKey(id);
    }

    /**
     * 添加服务
     * @param gallery
     * @return
     */
    @Override
    public int addGallery(Gallery gallery) {
        Gallery newGallery = new Gallery();
        newGallery.setAddress(gallery.getAddress());
        newGallery.setImgUrl(gallery.getImgUrl());
        newGallery.setGalleryDesc(gallery.getGalleryDesc());
        newGallery.setLiaocheng(gallery.getLiaocheng());
        newGallery.setOpenDate(gallery.getOpenDate());
        newGallery.setPirce(gallery.getPirce());
        newGallery.setStartDate(gallery.getStartDate());
        newGallery.setSuitPeople(gallery.getSuitPeople());
        newGallery.setTitle(gallery.getTitle());
        newGallery.setZuoyong(gallery.getZuoyong());
        return galleryMapper.insertSelective(newGallery);
    }
}
